<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$return=array();
$setting=core_setting('sms');
if($setting['all_sys']){
	//exi('本系统暂不支持设置自定义短信接口！','error','goback');
}
$tabs=array(
			array('op'=>'get','title'=>'系统短信设置'),
);
if($_RQ['op']=='get'){
	$value=uni_setting('sms');
	$return['item']=$value?$value:array();
	$return['plugins']=pdo_getall('core_plugins',array('name'=>array('jy_alisms','jy_juhesms','jy_dxton')),array('name','title'));
	foreach($return['plugins'] as $item){
		if($item['name']=='jy_alisms'){
			$tabs[]=array('action'=>'jy_alisms/dayusetting/','title'=>$item['title']);
		}
		if($item['name']=='jy_juhesms'){
			$tabs[]=array('action'=>'jy_juhesms/juhesetting/','title'=>$item['title']);
		}
		if($item['name']=='jy_dxton'){
			$tabs[]=array('action'=>'jy_dxton/dxtsetting/','title'=>$item['title']);
		}
	}
	$register=uni_setting('register');
	$return['item']['dxmb']=$register['dxmb'];
	$htmls=array(
		'type'=>'edit',
		'post'=>'post',
		'desc'=>'设置页面信息',
		'tabs'=>$tabs,
		'edit'=>array(
			array('type'=>'tip','title'=>'<red>选择不同的短信接口后，需要点击上面的菜单，设置不同短信接口的参数；【注意】：如果选择了阿里云通信，需要单独设置不同的模板ID，例如：短信验证码，需要前往《站点注册设置》，设置“验证码短信模版ID”</red>'),
			array('type'=>'select','title'=>'主接口选择','name'=>'plugin', 'options'=>'plugins','option_value'=>'name','help'=>'默认发送短信的接口' ),
			array('type'=>'select','title'=>'备用接口选择','name'=>'plugin1', 'options'=>'plugins','option_value'=>'name','help'=>'当主接口发送短信失败时，尝试调用此接口' ),
			array('type'=>'string','title'=>'验证码短信模版ID','name'=>'dxmb','help'=>'本短信模版不仅用于登陆、注册验证，系统短信验证码接口也使用本模版！'),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='post'){
	$postdata=get_postdata();
	if($postdata['dxmb']){
		$register=uni_setting('register');
		$register['dxmb']=$postdata['dxmb'];
		uni_setting('register',$register);
		unset($postdata['dxmb']);
	}
	uni_setting('sms',$postdata);
	exi('系统短信设置成功！');
}